1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package sun.awt;
27
28 import java.awt.RenderingHints;
29
30
31
32
33
34
35
36 public class SunHints {
37
38
39
40
41
42
43
44 public static class Key extends RenderingHints.Key {
45 String description;
46
47
48
49
50
51
52
53
54
55
56 public Key(int privatekey, String description) {
57 super(privatekey);
58 this.description = description;
59 }
60
61
62
63
64
65
66 public final int getIndex() {
67 return intKey();
68 }
69
70
71
72
73 public final String toString() {
74 return description;
75 }
76
77
78
79
80
81 public boolean isCompatibleValue(Object val) {
82 if (val instanceof Value) {
83 return ((Value)val).isCompatibleKey(this);
84 }
85 return false;
86 }
87 }
88
89
90
91
92
93
94
95
96 public static class Value {
97 private SunHints.Key myKey;
98 private int index;
99 private String description;
100
101 private static Value[][] ValueObjects =
102 new Value[NUM_KEYS][VALS_PER_KEY];
103
104 private synchronized static void register(SunHints.Key key,
105 Value value) {
106 int kindex = key.getIndex();
107 int vindex = value.getIndex();
108 if (ValueObjects[kindex][vindex] != null) {
109 throw new InternalError("duplicate index: "+vindex);
110 }
111 ValueObjects[kindex][vindex] = value;
112 }
113
114 public static Value get(int keyindex, int valueindex) {
115 return ValueObjects[keyindex][valueindex];
116 }
117
118
119
120
121
122
123
124 public Value(SunHints.Key key, int index, String description) {
125 this.myKey = key;
126 this.index = index;
127 this.description = description;
128
129 register(key, this);
130 }
131
132
133
134
135
136
137 public final int getIndex() {
138 return index;
139 }
140
141
142
143
144 public final String toString() {
145 return description;
146 }
147
148
149
150
151
152 public final boolean isCompatibleKey(Key k) {
153 return myKey == k;
154 }
155
156
157
158
159
160
161 public final int hashCode() {
162 return System.identityHashCode(this);
163 }
164
165
166
167
168
169 public final boolean equals(Object o) {
170 return this == o;
171 }
172 }
173
174 private static final int NUM_KEYS = 9;
175 private static final int VALS_PER_KEY = 8;
176
177
178
179
180 public static final int INTKEY_RENDERING = 0;
181 public static final int INTVAL_RENDER_DEFAULT = 0;
182 public static final int INTVAL_RENDER_SPEED = 1;
183 public static final int INTVAL_RENDER_QUALITY = 2;
184
185
186
187
188 public static final int INTKEY_ANTIALIASING = 1;
189 public static final int INTVAL_ANTIALIAS_DEFAULT = 0;
190 public static final int INTVAL_ANTIALIAS_OFF = 1;
191 public static final int INTVAL_ANTIALIAS_ON = 2;
192
193
194
195
196 public static final int INTKEY_TEXT_ANTIALIASING = 2;
197 public static final int INTVAL_TEXT_ANTIALIAS_DEFAULT = 0;
198 public static final int INTVAL_TEXT_ANTIALIAS_OFF = 1;
199 public static final int INTVAL_TEXT_ANTIALIAS_ON = 2;
200 public static final int INTVAL_TEXT_ANTIALIAS_GASP = 3;
201 public static final int INTVAL_TEXT_ANTIALIAS_LCD_HRGB = 4;
202 public static final int INTVAL_TEXT_ANTIALIAS_LCD_HBGR = 5;
203 public static final int INTVAL_TEXT_ANTIALIAS_LCD_VRGB = 6;
204 public static final int INTVAL_TEXT_ANTIALIAS_LCD_VBGR = 7;
205
206
207
208
209 public static final int INTKEY_FRACTIONALMETRICS = 3;
210 public static final int INTVAL_FRACTIONALMETRICS_DEFAULT = 0;
211 public static final int INTVAL_FRACTIONALMETRICS_OFF = 1;
212 public static final int INTVAL_FRACTIONALMETRICS_ON = 2;
213
214
215
216
217 public static final int INTKEY_DITHERING = 4;
218 public static final int INTVAL_DITHER_DEFAULT = 0;
219 public static final int INTVAL_DITHER_DISABLE = 1;
220 public static final int INTVAL_DITHER_ENABLE = 2;
221
222
223
224
225 public static final int INTKEY_INTERPOLATION = 5;
226 public static final int INTVAL_INTERPOLATION_NEAREST_NEIGHBOR = 0;
227 public static final int INTVAL_INTERPOLATION_BILINEAR = 1;
228 public static final int INTVAL_INTERPOLATION_BICUBIC = 2;
229
230
231
232
233 public static final int INTKEY_ALPHA_INTERPOLATION = 6;
234 public static final int INTVAL_ALPHA_INTERPOLATION_DEFAULT = 0;
235 public static final int INTVAL_ALPHA_INTERPOLATION_SPEED = 1;
236 public static final int INTVAL_ALPHA_INTERPOLATION_QUALITY = 2;
237
238
239
240
241 public static final int INTKEY_COLOR_RENDERING = 7;
242 public static final int INTVAL_COLOR_RENDER_DEFAULT = 0;
243 public static final int INTVAL_COLOR_RENDER_SPEED = 1;
244 public static final int INTVAL_COLOR_RENDER_QUALITY = 2;
245
246
247
248
249 public static final int INTKEY_STROKE_CONTROL = 8;
250 public static final int INTVAL_STROKE_DEFAULT = 0;
251 public static final int INTVAL_STROKE_NORMALIZE = 1;
252 public static final int INTVAL_STROKE_PURE = 2;
253
254
255
256
257
258
259 public static final int INTKEY_AATEXT_LCD_CONTRAST = 100;
260
261
262
263
264 public static final Key KEY_RENDERING =
265 new SunHints.Key(SunHints.INTKEY_RENDERING,
266 "Global rendering quality key");
267 public static final Object VALUE_RENDER_SPEED =
268 new SunHints.Value(KEY_RENDERING,
269 SunHints.INTVAL_RENDER_SPEED,
270 "Fastest rendering methods");
271 public static final Object VALUE_RENDER_QUALITY =
272 new SunHints.Value(KEY_RENDERING,
273 SunHints.INTVAL_RENDER_QUALITY,
274 "Highest quality rendering methods");
275 public static final Object VALUE_RENDER_DEFAULT =
276 new SunHints.Value(KEY_RENDERING,
277 SunHints.INTVAL_RENDER_DEFAULT,
278 "Default rendering methods");
279
280
281
282
283 public static final Key KEY_ANTIALIASING =
284 new SunHints.Key(SunHints.INTKEY_ANTIALIASING,
285 "Global antialiasing enable key");
286 public static final Object VALUE_ANTIALIAS_ON =
287 new SunHints.Value(KEY_ANTIALIASING,
288 SunHints.INTVAL_ANTIALIAS_ON,
289 "Antialiased rendering mode");
290 public static final Object VALUE_ANTIALIAS_OFF =
291 new SunHints.Value(KEY_ANTIALIASING,
292 SunHints.INTVAL_ANTIALIAS_OFF,
293 "Nonantialiased rendering mode");
294 public static final Object VALUE_ANTIALIAS_DEFAULT =
295 new SunHints.Value(KEY_ANTIALIASING,
296 SunHints.INTVAL_ANTIALIAS_DEFAULT,
297 "Default antialiasing rendering mode");
298
299
300
301
302 public static final Key KEY_TEXT_ANTIALIASING =
303 new SunHints.Key(SunHints.INTKEY_TEXT_ANTIALIASING,
304 "Text-specific antialiasing enable key");
305 public static final Object VALUE_TEXT_ANTIALIAS_ON =
306 new SunHints.Value(KEY_TEXT_ANTIALIASING,
307 SunHints.INTVAL_TEXT_ANTIALIAS_ON,
308 "Antialiased text mode");
309 public static final Object VALUE_TEXT_ANTIALIAS_OFF =
310 new SunHints.Value(KEY_TEXT_ANTIALIASING,
311 SunHints.INTVAL_TEXT_ANTIALIAS_OFF,
312 "Nonantialiased text mode");
313 public static final Object VALUE_TEXT_ANTIALIAS_DEFAULT =
314 new SunHints.Value(KEY_TEXT_ANTIALIASING,
315 SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT,
316 "Default antialiasing text mode");
317 public static final Object VALUE_TEXT_ANTIALIAS_GASP =
318 new SunHints.Value(KEY_TEXT_ANTIALIASING,
319 SunHints.INTVAL_TEXT_ANTIALIAS_GASP,
320 "gasp antialiasing text mode");
321 public static final Object VALUE_TEXT_ANTIALIAS_LCD_HRGB =
322 new SunHints.Value(KEY_TEXT_ANTIALIASING,
323 SunHints.INTVAL_TEXT_ANTIALIAS_LCD_HRGB,
324 "LCD HRGB antialiasing text mode");
325 public static final Object VALUE_TEXT_ANTIALIAS_LCD_HBGR =
326 new SunHints.Value(KEY_TEXT_ANTIALIASING,
327 SunHints.INTVAL_TEXT_ANTIALIAS_LCD_HBGR,
328 "LCD HBGR antialiasing text mode");
329 public static final Object VALUE_TEXT_ANTIALIAS_LCD_VRGB =
330 new SunHints.Value(KEY_TEXT_ANTIALIASING,
331 SunHints.INTVAL_TEXT_ANTIALIAS_LCD_VRGB,
332 "LCD VRGB antialiasing text mode");
333 public static final Object VALUE_TEXT_ANTIALIAS_LCD_VBGR =
334 new SunHints.Value(KEY_TEXT_ANTIALIASING,
335 SunHints.INTVAL_TEXT_ANTIALIAS_LCD_VBGR,
336 "LCD VBGR antialiasing text mode");
337
338
339
340
341 public static final Key KEY_FRACTIONALMETRICS =
342 new SunHints.Key(SunHints.INTKEY_FRACTIONALMETRICS,
343 "Fractional metrics enable key");
344 public static final Object VALUE_FRACTIONALMETRICS_ON =
345 new SunHints.Value(KEY_FRACTIONALMETRICS,
346 SunHints.INTVAL_FRACTIONALMETRICS_ON,
347 "Fractional text metrics mode");
348 public static final Object VALUE_FRACTIONALMETRICS_OFF =
349 new SunHints.Value(KEY_FRACTIONALMETRICS,
350 SunHints.INTVAL_FRACTIONALMETRICS_OFF,
351 "Integer text metrics mode");
352 public static final Object VALUE_FRACTIONALMETRICS_DEFAULT =
353 new SunHints.Value(KEY_FRACTIONALMETRICS,
354 SunHints.INTVAL_FRACTIONALMETRICS_DEFAULT,
355 "Default fractional text metrics mode");
356
357
358
359
360 public static final Key KEY_DITHERING =
361 new SunHints.Key(SunHints.INTKEY_DITHERING,
362 "Dithering quality key");
363 public static final Object VALUE_DITHER_ENABLE =
364 new SunHints.Value(KEY_DITHERING,
365 SunHints.INTVAL_DITHER_ENABLE,
366 "Dithered rendering mode");
367 public static final Object VALUE_DITHER_DISABLE =
368 new SunHints.Value(KEY_DITHERING,
369 SunHints.INTVAL_DITHER_DISABLE,
370 "Nondithered rendering mode");
371 public static final Object VALUE_DITHER_DEFAULT =
372 new SunHints.Value(KEY_DITHERING,
373 SunHints.INTVAL_DITHER_DEFAULT,
374 "Default dithering mode");
375
376
377
378
379 public static final Key KEY_INTERPOLATION =
380 new SunHints.Key(SunHints.INTKEY_INTERPOLATION,
381 "Image interpolation method key");
382 public static final Object VALUE_INTERPOLATION_NEAREST_NEIGHBOR =
383 new SunHints.Value(KEY_INTERPOLATION,
384 SunHints.INTVAL_INTERPOLATION_NEAREST_NEIGHBOR,
385 "Nearest Neighbor image interpolation mode");
386 public static final Object VALUE_INTERPOLATION_BILINEAR =
387 new SunHints.Value(KEY_INTERPOLATION,
388 SunHints.INTVAL_INTERPOLATION_BILINEAR,
389 "Bilinear image interpolation mode");
390 public static final Object VALUE_INTERPOLATION_BICUBIC =
391 new SunHints.Value(KEY_INTERPOLATION,
392 SunHints.INTVAL_INTERPOLATION_BICUBIC,
393 "Bicubic image interpolation mode");
394
395
396
397
398 public static final Key KEY_ALPHA_INTERPOLATION =
399 new SunHints.Key(SunHints.INTKEY_ALPHA_INTERPOLATION,
400 "Alpha blending interpolation method key");
401 public static final Object VALUE_ALPHA_INTERPOLATION_SPEED =
402 new SunHints.Value(KEY_ALPHA_INTERPOLATION,
403 SunHints.INTVAL_ALPHA_INTERPOLATION_SPEED,
404 "Fastest alpha blending methods");
405 public static final Object VALUE_ALPHA_INTERPOLATION_QUALITY =
406 new SunHints.Value(KEY_ALPHA_INTERPOLATION,
407 SunHints.INTVAL_ALPHA_INTERPOLATION_QUALITY,
408 "Highest quality alpha blending methods");
409 public static final Object VALUE_ALPHA_INTERPOLATION_DEFAULT =
410 new SunHints.Value(KEY_ALPHA_INTERPOLATION,
411 SunHints.INTVAL_ALPHA_INTERPOLATION_DEFAULT,
412 "Default alpha blending methods");
413
414
415
416
417 public static final Key KEY_COLOR_RENDERING =
418 new SunHints.Key(SunHints.INTKEY_COLOR_RENDERING,
419 "Color rendering quality key");
420 public static final Object VALUE_COLOR_RENDER_SPEED =
421 new SunHints.Value(KEY_COLOR_RENDERING,
422 SunHints.INTVAL_COLOR_RENDER_SPEED,
423 "Fastest color rendering mode");
424 public static final Object VALUE_COLOR_RENDER_QUALITY =
425 new SunHints.Value(KEY_COLOR_RENDERING,
426 SunHints.INTVAL_COLOR_RENDER_QUALITY,
427 "Highest quality color rendering mode");
428 public static final Object VALUE_COLOR_RENDER_DEFAULT =
429 new SunHints.Value(KEY_COLOR_RENDERING,
430 SunHints.INTVAL_COLOR_RENDER_DEFAULT,
431 "Default color rendering mode");
432
433
434
435
436 public static final Key KEY_STROKE_CONTROL =
437 new SunHints.Key(SunHints.INTKEY_STROKE_CONTROL,
438 "Stroke normalization control key");
439 public static final Object VALUE_STROKE_DEFAULT =
440 new SunHints.Value(KEY_STROKE_CONTROL,
441 SunHints.INTVAL_STROKE_DEFAULT,
442 "Default stroke normalization");
443 public static final Object VALUE_STROKE_NORMALIZE =
444 new SunHints.Value(KEY_STROKE_CONTROL,
445 SunHints.INTVAL_STROKE_NORMALIZE,
446 "Normalize strokes for consistent rendering");
447 public static final Object VALUE_STROKE_PURE =
448 new SunHints.Value(KEY_STROKE_CONTROL,
449 SunHints.INTVAL_STROKE_PURE,
450 "Pure stroke conversion for accurate paths");
451
452
453 public static class LCDContrastKey extends Key {
454
455 public LCDContrastKey(int privatekey, String description) {
456 super(privatekey, description);
457 }
458
459
460
461
462
463 public final boolean isCompatibleValue(Object val) {
464 if (val instanceof Integer) {
465 int ival = ((Integer)val).intValue();
466 return ival >= 100 && ival <= 250;
467 }
468 return false;
469 }
470
471 }
472
473
474
475
476 public static final RenderingHints.Key
477 KEY_TEXT_ANTIALIAS_LCD_CONTRAST =
478 new LCDContrastKey(SunHints.INTKEY_AATEXT_LCD_CONTRAST,
479 "Text-specific LCD contrast key");
480 }